const {
  getList,
  getswipsrc,
  getproductlist
} = require("../../http/api.js")
Page({
  onShareAppMessage() {
    return {
      title: 'swiper',
      path: 'page/component/pages/swiper/swiper',
    }
  },
  data: {
    background: [],
    navsrc: [],
    indicatorDots: true,
    vertical: false,
    autoplay: true,
    interval: 2000,
    duration: 500,
    productlist: [],
    page: 1
  },

  changeIndicatorDots() {
    this.setData({
      indicatorDots: !this.data.indicatorDots
    })
  },
  seackclick() {
    wx.navigateTo({
      url: '../../pages/seach/seach',
    })
  },
  onReady() {

    /分类接口 /
    getList().then(res => {
        this.setData({
          navsrc: res.data.data
        })
      }),
      /轮播图接口 /
    getswipsrc().then(res => {
        this.setData({
          background: res.data.data.slice(3, 6)
        })
      }),


      /商品列表接口 /
    getproductlist().then(res => {
      this.setData({
        productlist: res.data.data.result,
      })
      console.log(this.data.productlist);
    })
  },
  changeAutoplay() {
    this.setData({
      autoplay: !this.data.autoplay
    })
  },
  intervalChange(e) {
    this.setData({
      interval: e.detail.value
    })
  },
  durationChange(e) {
    this.setData({
      duration: e.detail.value
    })
  },
  toclassify(e) {
    wx.reLaunch({
      url: '../../pages/classify/classify?id=' + e.currentTarget.dataset.id
    })
  },
  onReachBottom() {
    this.data.page++
  },
  godetails(e) {
    console.log(e.currentTarget.dataset.id);
    wx.navigateTo({
      url: '../../pages/details/details?id='+e.currentTarget.dataset.id,
    })
  }
})